<%@ page import="mpay.Registration" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <g:set var="entityName" value="${message(code: 'registration.label', default: 'Registration')}"/>
  <title><g:message code="default.create.label" args="[entityName]"/></title>
  <script type="text/javascript">
    $(function() {
      $('#checkBank').click(function(){
        alert('hey');
      });
    });

  </script>
</head>

<body>
<div class="nav">
  <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a>
  </span>
  <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label"
                                                                         args="[entityName]"/></g:link></span>
</div>

<div class="body">
  <h1>Register your mobile with MPay</h1>
  <div>Pay your products and services via MPay using SMS.</div>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <g:hasErrors bean="${registrationInstance}">
    <div class="errors">
      <g:renderErrors bean="${registrationInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <g:form action="save">
    <div class="dialog">
      <table>
        <tbody>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="firstName"><g:message code="registration.firstName.label" default="First Name"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'firstName', 'errors')}">
            <g:textField name="firstName" value="${registrationInstance?.firstName}"/>
          </td>
        </tr>
        
        <tr class="prop">
          <td valign="top" class="name">
            <label for="lastName"><g:message code="registration.lastName.label" default="Last Name"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'lastName', 'errors')}">
            <g:textField name="lastName" value="${registrationInstance?.lastName}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="gender"><g:message code="registration.gender.label" default="Gender"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'gender', 'errors')}">
            <g:radioGroup name="gender" labels="['Male','Female']" values="['M', 'F']">
              ${it.radio} ${it.label}
            </g:radioGroup>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="bankName.id"><g:message code="registration.bankName.label" default="Bank Name"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'bankName', 'errors')}">
            <g:select name="bankName.id" from="${mpay.Bank.listOrderByName()}" optionKey="id" optionValue="name"
            noSelection="['':'-Choose your bank-']"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="bankAccount"><g:message code="registration.bankAccount.label" default="Bank Account"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'bankAccount', 'errors')}">
            <g:textField name="bankAccount" value="${registrationInstance?.bankAccount}"/>
            <input id="checkBank" name="checkBank" value="Clich here to check bank avaiable" type="button" />
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="isActiveAccount"><g:message code="registration.isActiveAccount.label"
                                                    default="Is Active Account"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'isActiveAccount', 'errors')}">
            <g:checkBox name="isActiveAccount" value="${registrationInstance?.isActiveAccount}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="isSuccessRegister"><g:message code="registration.isSuccessRegister.label"
                                                      default="Is Success Register"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'isSuccessRegister', 'errors')}">
            <g:checkBox name="isSuccessRegister" value="${registrationInstance?.isSuccessRegister}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="mobile"><g:message code="registration.mobile.label" default="Mobile"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'mobile', 'errors')}">
            <g:textField name="mobile" value="${registrationInstance?.mobile}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="password"><g:message code="registration.password.label" default="Password"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'password', 'errors')}">
            <g:textField name="password" value="${registrationInstance?.password}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="confirmationCode"><g:message code="registration.confirmationCode.label"
                                                     default="Confirmation Code"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: registrationInstance, field: 'confirmationCode', 'errors')}">
            <g:textField name="confirmationCode" value="${registrationInstance?.confirmationCode}"/>
          </td>
        </tr>

        </tbody>
      </table>
    </div>

    <div class="buttons">
      <span class="button"><g:submitButton name="create" class="save"
                                           value="${message(code: 'default.button.create.label', default: 'Register')}"/></span>
    </div>
  </g:form>
</div>
</body>
</html>
